package com.quest.space.poker.base.config;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.quest.space.poker.dto.TableDto;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class CacheConfig {

    @Bean
    public Cache<String, TableDto> myCache() {
        return CacheBuilder.newBuilder()
                // 设置缓存的过期时间为1小时
                .expireAfterWrite(1000, TimeUnit.DAYS)
                // 设置缓存的最大容量
                .maximumSize(1000000)
                .build();
    }
}
